import request from "./ajax";

//数据路径
//const BASE_URL = "http://192.168.1.150:1892";
const BASE_URL = "https://contract-outer.shenzhoutongbao.cn";

//请求方法

//获取登录短信验证码
export function getSendCode(countryCode, cellphone) {
  const data = {
    countryCode,
    cellphone
  }
  return request({
    url: BASE_URL+'/contract/outer/sms/loginCode',
    method: 'post',
    data: data
  })
}
// 手机验证码登录
export function PhoneCodeLogin(countryCode, account, authCode, appKey) {
  const data = {
    countryCode,
    account,
    authCode,
    appKey
  }
  return request({
    url: BASE_URL+'/contract/outer/login/byPhone',
    method: 'post',
    data: data
  })
}
//获取注册短信验证码
export function getSendRegisterCode(countryCode, cellphone) {
  const data = {
    countryCode,
    cellphone
  }
  return request({
    url: BASE_URL+'/contract/outer/sms/registerCode',
    method: 'post',
    data: data
  })
}
// 手机验证码注册
export function PhoneCodeRegister(countryCode, account, authCode, appKey) {
  const data = {
    countryCode,
    account,
    authCode,
    appKey
  }
  return request({
    url: BASE_URL+'/contract/outer/login/register',
    method: 'post',
    data: data
  })
}
// 获取用户详细信息
export function getUserInFo() {
  return request({
    url: BASE_URL+'/contract/outer/user/currentUser',
    method: 'get'
  })
}
//退出登录
export function Logout() {
  return request({
    url: BASE_URL+'/contract/outer/login/logout',
    method: 'get'
  })
}

// ORC认证
export function credentialVerify(data) {
  return request({
    url: BASE_URL+'/contract/outer/userAuth/credentialVerify',
    method: 'post',
    data: data
  })
}

// 发送实名验证短信
export function getSenderVerifyCode(realName, cardNo) {
  const data = {
    realName,
    cardNo
  }
  return request({
    url: BASE_URL+'/contract/outer/userAuth/senderVerifyCode',
    method: 'post',
    data: data
  })
}

// 认证接口
export function userAuth(realName, cardNo, verifyCode, backFile, faceFile, identityType, gender) {
  const data = {
    realName,
    cardNo,
    verifyCode,
    backFile,
    faceFile,
    identityType,
    gender
  }
  return request({
    url: BASE_URL+'/contract/outer/userAuth/userAuth',
    method: 'post',
    data: data
  })
}


//获取签署合同URL
export function getUrlContract() {
  return request({
    url: BASE_URL+'/contract/outer/contract/getUrl',
    method: 'get'
  })
}



// 统计合同数
export function countContractSum() {
  return request({
    url: BASE_URL+'/contract/outer/contract/countContractSum',
    method: 'get'
  })
}
// 合同列表
export function contractList(query) {
  return request({
    url: BASE_URL+'/contract/outer/contract/contractList',
    method: 'get',
    params: query
  })
}
// 用户合同详情
export function contractMessage(contractId) {
  const data = {
    contractId
  }
  return request({
    url: BASE_URL+'/contract/outer/contract/contractMessage',
    method: 'post',
    data: data
  })
}
//合同预览
export function contractPreview(contractId) {
  const data = {
    contractId
  }
  return request({
    url: BASE_URL+'/contract/outer/contract/contractPreview',
    method: 'post',
    data: data
  })
}











export const getHomeCasual = () => ajax(BASE_URL + "/api/homecasual"); //首页轮播图

export const getHomeNav = () => ajax(BASE_URL + "/api/homenav"); // 请求首页的导航

export const getHomeShopList = () => ajax(BASE_URL + "/api/homeshoplist"); // 请求首页的商品列表

export const getRecommendShopList = params => ajax(BASE_URL + "/api/recommendshoplist", params); //获取推荐商品列表

export const getSearchGoods = () => ajax(BASE_URL + "/api/searchgoods"); //获取搜索分类列表数据

//export const pwdLogin = (name, pwd, captcha) => ajax(BASE_URL + "/api/login_pwt", { name, pwd, captcha }, "POST"); //用户名和密码登录

//export const getUserInFo = () => ajax(BASE_URL + "/contract/outer/user/currentUser"); //获取登录用户信息存储
export const UserUpdate = (
    user_id,
    user_name,
    user_sex,
    user_address,
    user_birthday,
    user_sign
) => ajax(BASE_URL + "/api/user_update", {
    user_id,
    user_name,
    user_sex,
    user_address,
    user_birthday,
    user_sign
}, "POST"); //修改用户信息

export const addCoodsCart = (user_id, goods_id, goods_name, thumb_url, price) =>
  ajax(BASE_URL + "/api/add_shop_cart", {
    user_id,
    goods_id,
    goods_name,
    thumb_url,
    price
  }, "POST"); //加入购物车


export const getCartShoping = () => ajax(BASE_URL + "/api/cart_goods"); // 请求购物车  